package dynamicProgramming;

public class Class746 {

    public int minCostClimbingStairs(int[] cost) {
        int[] dp=new int[cost.length+1];
        dp[0]=0;
        dp[1]=0;
        if (cost.length==1){
            return cost[0];
        }
        if (cost.length==2){
            return  Math.min(cost[0],cost[1]);
        }

        for (int i =2; i <=cost.length; i++) {
            dp[i]=Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
        }
        return  dp[cost.length];


    }

    public static void main(String[] args) {
        Class746 class746 = new Class746();
        int[] arr={10,15,20};
        System.out.println(class746.minCostClimbingStairs(arr));
    }
}
